/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Hua YY
 * Date: 2024-12-11
 * Time: 20:24
 */
class Solution1_1 {
    public String removeDuplicates(String ss) {
        //用数组模拟栈
        StringBuffer buffer = new StringBuffer();
        //先把字符串转化为字符数组，在进行遍历
        char[] s = ss.toCharArray();
        //在进行条件判断

        for(char ch : s){
            //如果栈不为空，并且ch == 栈顶元素，那就出栈
            if(buffer.length() > 0  && ch == buffer.charAt(buffer.length()-1)){
                buffer.deleteCharAt(buffer.length()-1);
            }else{ // 栈为空 或者 ch ！= 栈顶元素那就进栈
                buffer.append(ch);
            }
        }
        return buffer.toString();

    }
}
public class Test1_1 {
}
